function findNb(m) {
  if (m < 0) return '-1'
  let d = 1 + 8 * Math.sqrt(m)
  if (d < 0) return '-1'
  let x1 = (Math.sqrt(d) - 1) / 2
  if (x1 % 1 == 0 && x1 > 0) return x1
  let x2 = (-Math.sqrt(d) - 1) / 2
  if (x2 % 1 == 0 && x2 > 0) return x2
  return false
}

function findNb(m) {
  m = Math.sqrt(m) * 2;
  if (m != parseInt(m)) {
    return -1;
  }
  var result = parseInt(Math.sqrt(m));
  return (result * (result + 1) == m) ? result : -1;
}


function findNb(m) {
  var n = 0
  while (m > 0) m -= ++n ** 3
  return m ? -1 : n
}


function findNb(m) {
  let n = 0;
  let sum = 0;
  while (sum < m) {
    n++;
    sum += Math.pow(n, 3);
  }
  return sum === m ? n : -1;
}



console.log(findNb(135440716410000))

